<form  method="post" class="form-horizontal">
	<input type="hidden" name="id" value="{$privilege.id}">
	<div class="form-group">
		<label class="col-md-3 col-xs-12 control-label"></label>
		<div class="col-md-6 col-xs-12">
			<h2>保存权限</h2>
		</div>
	</div>

	<div class="form-group">
		<label class="col-md-3 col-xs-12 control-label">权限名称</label>
		<div class="col-md-6 col-xs-12">
			<input name="name" type="text" class="form-control" value="{$privilege.name}" />
		</div>
	</div>

	<div class="form-group">
		<label class="col-md-3 col-xs-12 control-label">权限URL</label>
		<div class="col-md-6 col-xs-12">
			<input name="url" type="text" class="form-control" value="{$privilege.url}" />
		</div>
	</div>

	<div class="form-group">
		<label class="col-md-3 col-xs-12 control-label">父权限</label>
		<div class="col-md-6 col-xs-12">
			<select data-am-selected name="parent_id">
				<option value="0">请选择父权限</option>
				<volist name='privilegeList' id='vo'>
					<neq name="vo.id" value="$privilege.id">
						<eq name="vo.id" value="$privilege.parent_id">
							<option value="{$vo.id}" selected>{$vo.level}{$vo.name}</option>
							<else/>
							<option value="{$vo.id}">{$vo.level}{$vo.name}</option>
						</eq>
					</neq>
				</volist>
			</select>
		</div>
	</div>

	<div class="form-group">
		<label class="col-md-3 col-xs-12 control-label">是否显示在菜单栏</label>
		<div class="col-md-6 col-xs-12">
			<!--<input name="number" type="text" class="form-control" value="{$privilege.number}" />-->
			<input type="radio" name="is_menu"   value="0" data-am-check <eq name="privilege.is_menu" value="0">checked="true"</eq>>不显示
			<input type="radio" name="is_menu" value="1" data-am-check <eq name="privilege.is_menu" value="1">checked="true"</eq>>显示
		</div>
	</div>

	<div>
		<div class="col-md-3 col-xs-12"></div>
		<div class="col-md-6 col-xs-12">
			<present name="errorNote">
				<div class="alert alert-danger" role="alert">
					<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
					<strong>{$errorNote}</strong>
				</div>
			</present>
			<div class="form-group">
				<div class="col-md-6"><input type="reset" class="btn btn-block btn-default" value=" 清 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 空 " /></div>
				<div class="col-md-6"><button type="button" class="btn btn-block btn-info pull-right" onclick="save()"> 提 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 交 </button></div>
			</div>
		</div>
	</div>
	<!-- Modal -->
	<div class="modal fade" id="my-alert" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
					<h4 class="modal-title" id="myModalLabel">提示</h4>
				</div>
				<div class="modal-body" id="hint_content">
				</div>
				<div class="modal-footer">
					<button type="button" id="close_btn" class="btn btn-default" data-dismiss="modal">关闭</button>
					<!--<button type="button" class="btn btn-primary">Save changes</button>-->
				</div>
			</div>
		</div>
	</div>
</form>
<script type="text/javascript">
	function save() {
		var id = $("[name='id']").val();
		var url = '';
		if(id == ''){
			url = '__URL__/add';
		}else{
			url = '__URL__/edit';
		}
		$.ajax({
			type: "POST",
			url: url,
			data: $('form').serialize(),
			dataType: "json",
			success: function (data) {
				$("#hint_content").empty().append(data.message);
				$("#my-alert").modal('show');
				if(data.check){
					$('#close_btn').attr('onclick','jump()');
				}
			},
			error: function (data) {
				console.info(data);
				$("#hint_content").empty().append("请求超时！");
				$("#my-alert").modal('show');
			}
		});
	}
	function jump() {
		window.location = '__URL__/';
	}
</script>